package com.atguigu.flink.chapter02_DataStreamAPI.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

/**
 * Created by Smexy on 2022/10/21
 *
 *  如何获取Source
 */
public class Demo1_GetSource
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //测试目的
        //从集合中获取Source
        DataStreamSource<String> ds2 = env.fromCollection(Arrays.asList("a", "b", "c"));
        ds2.print();

        //从若干元素中获取Source
        DataStreamSource<Integer> ds1 = env.fromElements(1, 2, 3, 4, 5);
        ds1.print();

        try {
                    env.execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }

    }
}
